/**
 * 项目名：phms3
 * 日期：    2019-11-23 18:57:26
 * Copyright (c) 2015- HTSC-版权所有
 */

package com.joysuch.wwyt.mh.entity;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_mh_monitoring_point")
@SQLDelete(sql = "update wwyt_mh_monitoring_point set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_mh_monitoring_point set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class MhMonitoringPoint implements java.io.Serializable {

    // columns START
    // ID
    private Long id;
    // 租户
    private Long tenentId;
    // 组织机构代码
    private String orgCode;
    // 名称
    @NotNull(field = "监测点名称")
    private String name;
    //
    @NotNull(field = "监测点编号")
    private String pointCode;
    // 数值单位
    private String unit;
    // 实时数值
    private String realtimeValue;
    // 实时数值更新时间
    private java.time.LocalDateTime realtimeValueUpdateTime;
    // 一级报警阈值
    private String level1Threshold;
    // 二级报警阈值
    private String level2Threshold;
    // 液位高高位
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "液位高高位,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String highValue2;
    // 液位高位
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "液位高位,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String highValue1;
    // 液位低位
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "液位低位,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String lowValue1;
    // 液位低低位
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "液位低低位,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String lowValue2;
    // 上限
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "量程上限,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String highValue;
    // 下限
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "量程下限,请输入整数或小数,小数位最多6位，最大不超过±999999")
    private String lowValue;

    // 采集频率
    private Integer defaultSamplingFrequency;
    //
    private Integer alarmSamplingFrequency;
    // 创建人
    private Long createBy;
    // 创建时间
    private java.time.LocalDateTime createTime;
    // 更新人
    private Long updateBy;
    // 更新时间
    private java.time.LocalDateTime updateTime;
    // 删除标记
    private String deleteFlag;
    // columns END
    // 动作
    private String alarmAction;
    // 开或者关
    private String switchs;
    // 监测点状态，启用或者关闭
    private Integer state;
    // 位置
    private String location;
    // 实质是数据的删除状态， 0 已删除; 1/null 未删除
    private Integer showState;

    // 责任部门
    @DataPermissionField(sqlColumn = "responsible_dept")
    private Long responsibleDept;

    @Column(name = "show_state")
    public Integer getShowState() {
        return showState;
    }

    public void setShowState(Integer showState) {
        this.showState = showState;
    }

    @Column(name = "SWITCHS", length = 2)
    public String getSwitchs() {
        return switchs;
    }

    public void setSwitchs(String switchs) {
        this.switchs = switchs;
    }

    @Column(name = "STATE")
    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @Column(name = "ALARM_ACTION", length = 100)
    public String getAlarmAction() {
        return alarmAction;
    }

    public void setAlarmAction(String alarmAction) {
        this.alarmAction = alarmAction;
    }

    public void setId(Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }

    @Column(name = "TENENT_ID", nullable = false)
    public Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(Long value) {
        this.tenentId = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(String value) {
        this.orgCode = value;
    }

    @Column(name = "NAME", length = 50, nullable = false)
    public String getName() {
        return this.name;
    }

    public void setName(String value) {
        this.name = value;
    }

    @Column(name = "POINT_CODE", length = 64, nullable = false)
    public String getPointCode() {
        return this.pointCode;
    }

    public void setPointCode(String value) {
        this.pointCode = value;
    }

    @Column(name = "UNIT", length = 10)
    public String getUnit() {
        return this.unit;
    }

    public void setUnit(String value) {
        this.unit = value;
    }

    @Column(name = "REALTIME_VALUE")
    public String getRealtimeValue() {
        return this.realtimeValue;
    }

    public void setRealtimeValue(String value) {
        this.realtimeValue = value;
    }

    @Column(name = "REALTIME_VALUE_UPDATE_TIME")
    public java.time.LocalDateTime getRealtimeValueUpdateTime() {
        return this.realtimeValueUpdateTime;
    }

    public void setRealtimeValueUpdateTime(java.time.LocalDateTime value) {
        this.realtimeValueUpdateTime = value;
    }

    @Column(name = "LEVEL1_THRESHOLD")
    public String getLevel1Threshold() {
        return this.level1Threshold;
    }

    public void setLevel1Threshold(String value) {
        this.level1Threshold = value;
    }

    @Column(name = "LEVEL2_THRESHOLD")
    public String getLevel2Threshold() {
        return this.level2Threshold;
    }

    public void setLevel2Threshold(String value) {
        this.level2Threshold = value;
    }

    @Column(name = "HIGH_VALUE2")
    public String getHighValue2() {
        return this.highValue2;
    }

    public void setHighValue2(String value) {
        this.highValue2 = value;
    }

    @Column(name = "HIGH_VALUE1")
    public String getHighValue1() {
        return this.highValue1;
    }

    public void setHighValue1(String value) {
        this.highValue1 = value;
    }

    @Column(name = "LOW_VALUE1")
    public String getLowValue1() {
        return this.lowValue1;
    }

    public void setLowValue1(String value) {
        this.lowValue1 = value;
    }

    @Column(name = "LOW_VALUE2")
    public String getLowValue2() {
        return this.lowValue2;
    }

    public void setLowValue2(String value) {
        this.lowValue2 = value;
    }

    @Column(name = "HIGH_VALUE")
    public String getHighValue() {
        return highValue;
    }

    public void setHighValue(String highValue) {
        this.highValue = highValue;
    }

    @Column(name = "LOW_VALUE")
    public String getLowValue() {
        return lowValue;
    }

    public void setLowValue(String lowValue) {
        this.lowValue = lowValue;
    }

    @Column(name = "DEFAULT_SAMPLING_FREQUENCY")
    public Integer getDefaultSamplingFrequency() {
        return this.defaultSamplingFrequency;
    }

    public void setDefaultSamplingFrequency(Integer value) {
        this.defaultSamplingFrequency = value;
    }

    @Column(name = "ALARM_SAMPLING_FREQUENCY")
    public Integer getAlarmSamplingFrequency() {
        return this.alarmSamplingFrequency;
    }

    public void setAlarmSamplingFrequency(Integer value) {
        this.alarmSamplingFrequency = value;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.time.LocalDateTime getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.time.LocalDateTime value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.time.LocalDateTime getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.time.LocalDateTime value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(String value) {
        this.deleteFlag = value;
    }

    @Column(name = "LOCATION", length = 128)
    public String getLocation() {
        return this.location;
    }

    public void setLocation(String value) {
        this.location = value;
    }

    /*
     * @Column(name = "CATEGORY_ID")
     * public Long getCategoryId() {
     * return this.categoryId;
     * }
     *
     * public void setCategoryId(Long value) {
     * this.categoryId = value;
     * }
     */
    private MhMonitoringType mhMonitoringType;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "MONITORING_TYPE_ID")
    @NotNull(field = "监测类型")
    public MhMonitoringType getMhMonitoringType() {
        return this.mhMonitoringType;
    }

    public void setMhMonitoringType(MhMonitoringType mhMonitoringType) {
        this.mhMonitoringType = mhMonitoringType;
    }

    @Column(name = "responsible_dept")
    public Long getResponsibleDept() {
        return responsibleDept;
    }

    public void setResponsibleDept(Long responsibleDept) {
        this.responsibleDept = responsibleDept;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
                .append("tenentId", getTenentId()).append("orgCode", getOrgCode()).append("name", getName())
                .append("pointCode", getPointCode()).append("unit", getUnit())
                .append("realtimeValue", getRealtimeValue())
                .append("realtimeValueUpdateTime", getRealtimeValueUpdateTime())
                .append("level1Threshold", getLevel1Threshold()).append("level2Threshold", getLevel2Threshold())
                .append("highValue2", getHighValue2()).append("highValue1", getHighValue1())
                .append("lowValue1", getLowValue1()).append("lowValue2", getLowValue2())
                .append("defaultSamplingFrequency", getDefaultSamplingFrequency())
                .append("alarmSamplingFrequency", getAlarmSamplingFrequency()).append("createBy", getCreateBy())
                .append("createTime", getCreateTime()).append("updateBy", getUpdateBy()).append("state", getState())
                .append("updateTime", getUpdateTime()).append("deleteFlag", getDeleteFlag())
                .append("location", getLocation()).append("categoryId").toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof MhMonitoringPoint == false)
            return false;
        if (this == obj)
            return true;
        MhMonitoringPoint other = (MhMonitoringPoint) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
